<?php
Junction_FileCabinet::using("Junction_Utils_Xml_Parser");
Junction_FileCabinet::using("Junction_Resources_Catalog");
Junction_FileCabinet::package("Test_Mock");

class Test_Junction_Utils_Xml_Parser extends UnitTestCase {
	
	private $_xmlString = '<property name="foo" column="bar" />';
	
	private $_xmlFile;
	
	public function __construct() {
		$this->_xmlFile = Junction_Resources_Catalog::fetch("test.xml");
	}
	
	public function testParseString() {
		$parser = new Junction_Utils_Xml_Parser();
		
		$stack = $parser->parse($this->_xmlString);
		$this->assertTrue($stack->size() == 0);
		
		$stack = $parser->parseFile($this->_xmlFile);
		$this->assertTrue($stack->size() == 0);
		
		$parser->setHandler("property", new Test_Mock_Handler());
		
		$stack = $parser->parse($this->_xmlString);
		$this->assertTrue($stack->size() == 1);
		$stack->pop();
		
		$stack = $parser->parseFile($this->_xmlFile);
		$this->assertTrue($stack->size() == 1);
		$stack->pop();
	}
}
?>